home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
taropyon
/
silib
/
silib.lzh
/
PRG
/
SDKFS
/
FSELDSP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-03
|
10KB
|
373 lines
/*************************************************************************
* âtâ@âCâïâZâîâNâ^
*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <msdos.cf>
#include <kbcode.h>
#include <sipd.h>
#include <sicoltbl.h>
#include <sifs.h>
#include <siptn.h>
#include "sdkfs.h"
#include "sdkfscf.h"
#if 0
+--+--------------------+--+
| | | |
|--+--------------------+--|
|A B C D E F G H I J K L M |
|N O P Q R S T U V W X Y Z |
|+----------------------+ |
|| |üú|
|| | |
|| | |
|| | |
|| | |
|| | |
|| |üÑ|
|+----------------------+ |
| |
+--------------------------+
#endif
extern int BlkDlgMoveEvFunc( int evNo, EVDAT_T *evdat );
static char *GetSizeStr( char *buf, size_t siz )
{
if ( siz < 1024 )
sprintf( buf, "%4uB", siz );
else if ( siz < 1024*1024 )
{
if ( siz < 100*1024 )
sprintf( buf, "%2u.%uK", siz / 1024, (100*(siz&1023)/1024)/10 );
else
sprintf( buf, "%4uK", siz / 1024 );
} else
{
if ( siz < 100*1024*1024 )
sprintf( buf, "%2u.%uM", siz / (1024*1024), (100*((siz/1024)&1023)/1024)/10 );
else
sprintf( buf, "%4uM", siz / (1024*1024) );
}
return (buf);
}
/*************************************************************************
* âtâ@âCâïû╝êΩùùé╠ò\Ī
*************************************************************************/
void FileSel_dspFndat( FILESEL_T *fs, int pos )
{
int i, y;
CONST int x1 = fs->frFl.x1, x2 = fs->frFl.x2;
LAYER_T *ly = SiScn->layerCrt;
{
SB_T *sb = fs->sb;
sb->total = fs->numMat;
sb->min = 0;
sb->max = fs->numMat - 1;
sb->top = fs->posDspTop;
sb->wid = FSDSP_FNUM;
}
MOS_DEC();
for ( i = 0; i < FSDSP_FNUM; ++i )
{
int p;
p = fs->posDspTop + i;
y = fs->frFl.y1 + 2 + i * 12;
if ( pos < 0 || pos == p )
{
if ( fs->posDspTop + i < fs->numMat )
{
FNDAT_T *fndat;
char tmp[32], fn[16], sub[8];
COLOR_T col, bac;
fndat = fs->fnMat[fs->posDspTop + i];
FS_getFn(fn ,fndat->buf.name);
FS_getSn(sub,fndat->buf.name);
bac = ly->col.black;
if ( fndat->buf.attrib & FSATT_DIR )
{ /* âfâBâîâNâgâè */
col = C_HYELLOW;
sprintf( tmp,"%-8s.%-3s <DIR>", fn, sub );
} else
{
char buf[8];
switch ( fndat->buf.attrib & (FSATT_SYS|FSATT_RO) )
{
case FSATT_SYS:
col = ly->colTbl[8+1];
break;
case FSATT_RO:
col = ly->colTbl[8+2];
break;
case FSATT_SYS|FSATT_RO:
col = ly->colTbl[8+3];
break;
default:
col = ly->col.gray;
break;
}
sprintf( tmp,"%-8s.%-3s %s",
fn, sub, GetSizeStr(buf,fndat->buf.size) );
}
if ( fndat->mark )
{
COLOR_T memo;
memo = col, col = bac, bac = memo;
}
/* SCN_BOXF(x1,y,x2,y+11,PSET,bac); */
SCN_PUTS(SiFts->ftsSs2,tmp,x1+2,y,OPAQUE,col,bac);
if ( pos < 0 )
{
EV_SETFR(fs->evFn, i, p, fs, fsEvFunc_file,
NULL, EVSW_LEFT,x1,y,x2,y+11);
}
} else
{
SCN_BOXF(x1,y,x2,y+11,PSET,ly->col.black);
if ( pos < 0 )
EV_datUnset( fs->evFn, i);
}
if ( pos == p )
break;
}
}
MOS_INC();
}
/*************************************************************************
* ôⁿù═âtâ@âCâïû╝é╠ò\Ī
*************************************************************************/
void FileSel_dspFnbuf( FILESEL_T *fs )
{
LAYER_T *ly = SiScn->layerCrt;
int xx1 = fs->fr.x1 + 2, yy1 = fs->fr.y2+1 - 2 - 12;
int xx2 = fs->frFl.x2-1, yy2 = yy1 + 11;
MOS_DEC();
SCN_BOXF(xx1,yy1,xx2,yy2,PSET,ly->col.black);
if ( fs->buf[0] )
{
char tmp[80];
FS_getFnam( tmp, fs->buf );
SCN_PUTS(SiFts->ftsSs2,tmp,xx1+2,yy1,OPAQUE,ly->col.gray,ly->col.black);
}
MOS_INC();
}
/*************************************************************************
* âGâëü[ò\Ī
*************************************************************************/
void FileSel_dspErr(FILESEL_T *fs)
{
CONST int x1 = fs->frFl.x1+1, x2 = fs->frFl.x2-1;
CONST int y1 = fs->frFl.y1+1, y2 = fs->frFl.y2-1;
LAYER_T *ly = SiScn->layerCrt;
char *msg;
MOS_DEC();
SCN_BOXF(x1,y1,x2,y2,PSET,ly->col.black);
switch ( fs->err )
{
case FSERR_DRIVE: msg = "Drive not ready"; break;
case FSERR_FILE: msg = "File not found"; break;
case FSERR_MEMORY: msg = "Memory error"; break;
default: msg = "Sdkfs error"; break;
}
SCN_PUTS(SiFts->ftsSs2,msg,x1+2,(y1+y2-12)/2,OPAQUE,ly->colTbl[8+2],ly->col.black);
MOS_INC();
}
/*************************************************************************
* â_âCâAâìâOò\Īè╓Éö
*************************************************************************/
void fsFunc_dlgdsp( BLKDLG_T *dlg )
{
FILESEL_T *fs = dlg->ptr;
int x1 = dlg->rect.x0 + 2;
int y1 = dlg->rect.y0 + 2;
int x2 = dlg->rect.x0 + dlg->rect.xs - 1 -2;
int y2 = dlg->rect.y0 + dlg->rect.ys - 1 -2;
EV_T *ev = fs->ev;
int evPos = 0;
void *win = NULL;
LAYER_T *ly = SiScn->layerCrt;
CONST COLOR_T sha = ly->col.dark, hil = ly->col.white;
fs->fr.x1 = x1;
fs->fr.y1 = y1;
fs->fr.x2 = x2;
fs->fr.y2 = y2;
/* âNâìü[âYâ{â^âô ------------------------------------------------*/
{
CONST int xx1 = x1 , yy1 = y1;
CONST int xx2 = x1+15, yy2 = y1+15;
SCN_PUTIMGPTN( &Ptn16x16_close, xx1, yy1, OPAQUE, ly->col.black,ly->col.gray);
SCN_BOXCON(xx1,yy1,xx2,yy2,1,PSET,hil, sha);
EV_SETBTN1(ev,evPos++, FSEV_EXIT, fs, fsEvFunc_exit,
win, EVSW_LEFT,xx1,yy1,xx2,yy2,1,hil,sha);
}
/* â^âCâgâï --------------------------------------------------------*/
{
CONST int xx1 = x1 + 16, yy1 = y1;
CONST int xx2 = x2 - 16, yy2 = y1 + 15;
SCN_BOXFCON(xx1,yy1,xx2,yy2,1,PSET,ly->col.gray,hil,sha);
EV_SETFR(ev,evPos++, 0, dlg,BlkDlgMoveEvFunc,win,EVSW_LEFT,
xx1, yy1, xx2, yy2);
if ( fs->title )
{
SCN_PUTS(SiFts->ftsSs2,fs->title,xx1+3,yy1+3,OPAQUE,ly->col.white,ly->col.gray);
SCN_PUTS(SiFts->ftsSs2,fs->title,xx1+2,yy1+2,PSET ,ly->col.black,ly->col.gray);
}
}
/* âëâCâgâ{â^âôâüâjâàü[ --------------------------------------------*/
{
CONST int xx1 = x2-15, yy1 = y1;
CONST int xx2 = x2, yy2 = y1+15;
SCN_PUTIMGPTN( &Ptn16x16_menu, xx1, yy1, OPAQUE, ly->col.black, ly->col.gray);
SCN_BOXCON(xx1,yy1,xx2,yy2,1,PSET,hil,sha);
EV_SETBTN1(ev,evPos++,0,fs,fsEvFunc_rightMenu,win,
EVSW_LEFT,xx1,yy1,xx2,yy2,1,hil,sha);
}
/* âhâëâCâuâZâîâNâ^ ------------------------------------------------*/
fs->frDrv.x1 = x1 + 2;
fs->frDrv.y1 = y1 + 16 + 2;
fs->frDrv.x2 = x2 - 2;
fs->frDrv.y2 = y1 + 16 + 2 + 2+14+2+14+2 -1;
FileSel_dspDrv( fs );
/* âtâ@âCâïû╝ò\Īÿg ------------------------------------------------*/
fs->frFl.x1 = x1 + 2;
fs->frFl.y1 = fs->frDrv.y2+1+1;
fs->frFl.x2 = x2 - 2 -16 - 2;
fs->frFl.y2 = y2 - (2+12+2);
SCN_BOXF(fs->frFl.x1,fs->frFl.y1,fs->frFl.x2,fs->frFl.y2,PSET,ly->col.black);
if ( fs->err != FSERR_NOERR )
{
if ( fs->err == FSERR_UNREAD )
FileSel_changedir( fs );
}
if ( fs->err == FSERR_NOERR )
{ /* ò\Īé╖éΘ */
FileSel_dspFndat( fs, -1 );
} else
FileSel_dspErr(fs);
/* âXâNâìü[âïâoü[ ------------------------------------------------*/
{
SB_T *sb = fs->sb;
FRAME_T fr;
fr.x1 = fs->frFl.x2 + 1 + 3;
fr.y1 = fs->frFl.y1;
fr.x2 = x2+1 - 3;
fr.y2 = y2-2-16-2;
SB_vDsp( sb, &fr );
}
/* ôⁿù═âtâ@âCâïû╝ ------------------------------------------------*/
FileSel_dspFnbuf( fs );
/* [âèâ^ü[âô]âLü[â{â^âô --------------------------------------------*/
{
CONST int xx1 = x2+1-16-2 -1, yy1 = y2+1-2-16 - 1;
CONST int xx2 = xx1 + 15 +2, yy2 = yy1 + 15 + 2;
SCN_BOXFCON(xx1,yy1,xx2,yy2,1,PSET, ly->col.gray, hil, sha);
SCN_PUTIMGPTN( &Ptn16x16_return, xx1+1, yy1+1, OPAQUE, ly->col.white,